package com.qike.duola.enums;

import com.qike.duola.vo.EnumList;

import java.util.ArrayList;
import java.util.List;

/**
 * 来源类型 0 工程 1报价单 2 合同 3 内部采购 4 采购合同',
 * 来源类型 0 工程 1报价单 2 合同 3 内部采购 4 采购合同',
 */
public enum MessageTypeEnums {
    system                 (0,"系统"),
    active                      (1,"活动"),
    ;
    private Integer ecode;

    private String emsg;

    MessageTypeEnums(Integer ecode, String emsg) {
        this.ecode = ecode;
        this.emsg = emsg;
    }

    public Integer getEcode() {
        return ecode;
    }

    public String getEmsg() {
        return emsg;
    }

    public static MessageTypeEnums statOf(Integer ecode) {
        for (MessageTypeEnums state : values())
            if (state.getEcode().equals(ecode))
                return state;
        return null;
    }

    public static List<EnumList> getEnumList(){
        List<EnumList> lists = new ArrayList<>();
        for (MessageTypeEnums state : values()){
            EnumList enumList = new EnumList();
            enumList.setKey(state.getEcode());
            enumList.setValue(state.getEmsg());
            lists.add(enumList);
        }
        return lists;
    }
}
